package com.boot.proofing.mpweb.base.entity.enums;

import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.HashMap;
import java.util.Map;

/**
 * @description
 * @autor xbwu on 2018/5/25.
 */
public enum SexEnums implements IEnum<Integer> {
    MAN(1, "男"),WOMAN(2, "女"),SECRET(3,"保密");

    private static Map<Integer, SexEnums> valueMap = new HashMap<>();

    private int value;
    private String desc;

    static {
        for(SexEnums sexEnum : SexEnums.values()) {
            valueMap.put(sexEnum.value, sexEnum);
        }
    }
    SexEnums(final int value, final String desc) {
        this.value = value;
        this.desc = desc;
    }

    @Override
    public Integer getValue() {
        return this.value;
    }

    @JsonValue
    public String getDesc(){
        return this.desc;
    }


    public static SexEnums getByValue(int value) {
        SexEnums result = valueMap.get(value);
        if(result == null) {
            throw new IllegalArgumentException("No element matches " + value);
        }
        return result;
    }
}
